package com.ecommerce.dto;

import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 业务通用API响应封装
 */
@Data
@ApiModel("业务通用API响应")
public class BusApiResponse<T> {
    @ApiModelProperty(value = "响应码", example = "200")
    private int code;

    @ApiModelProperty(value = "响应消息")
    private String message;

    @ApiModelProperty(value = "响应数据")
    private T data;

    @ApiModelProperty(value = "响应时间戳")
    private long timestamp = System.currentTimeMillis();

    public static <T> BusApiResponse<T> success(T data) {
        BusApiResponse<T> response = new BusApiResponse<>();
        response.setCode(200);
        response.setMessage("success");
        response.setData(data);
        return response;
    }

    public static <T> BusApiResponse<T> fail(String message) {
        BusApiResponse<T> response = new BusApiResponse<>();
        response.setCode(500);
        response.setMessage(message);
        return response;
    }

    // 可以添加更多静态工厂方法...
}